{% extends 'layout.html' %}

{% block main %}
<ol class="breadcrumb">
  <li><a href="/admin">管理首页</a></li>
  <li class="active">内容首页</li>
</ol>

<h1 class="page-header">内容首页</h1>
{% set a = 'content' %}
{% include 'page.html' %}

<div class="table-responsive">
  <table class="table table-striped table-hover">
    <thead>
      <tr>
        <th>分类名称</th>
        <th>ID</th>
        <th>标题</th>
        <th>作者</th>
        <th>添加时间</th>
        <th>阅读量</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>

      {% for content in contents %}
      <tr>
        <td> {{content.category.name}} </td>
        <td> {{content._id.toString()}} </td>
        <td> {{content.title}} </td>
        <td> {{content.user.username}} </td>
        <td> {{content.addTime|date('Y年m月d日 H:i:s', -8 * 60)}} </td>
        <td> {{content.views}} </td>
        <td>
          <a href="/admin/content/edit?id={{content._id.toString()}}">修改</a> |
          <a href="/admin/content/delete?id={{content._id.toString()}}">删除</a>
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>

{% endblock %}